#! /bin/sh

#容器列表
dockerlist=`docker ps | grep -v "pause\|filebeat\|traefik" | awk '{print $1}' | grep -v CONTAINER` 

#存储路径
#RESULTFILE="/app/paasadmin/sortDocker.txt"

echo "容器名        进程数        句柄总数        容器名" > $RESULTFILE
for v in ${dockerlist[@]}
  do
    result1=`docker container top $v | awk 'NR == 1 {next}{print$2}' | wc -l`
    result2=`docker container top $v | awk 'NR == 1 {next}{print$2}'| xargs -i ls -l /proc/{}/fd | wc -l`
    podName=`docker inspect $v | grep -iw "io.kubernetes.pod.name" | awk '{print $2}' | awk -F "," '{print $1}'`
    echo $v"        "$result1"        "$result2"        "$podName #>> $RESULTFILE
  done
